package com.itheima.controller;

import com.itheima.common.PageResult;
import com.itheima.common.ResultData;
import com.itheima.domain.SmsFlashPromotionProductRelation;
import com.itheima.service.SmsFlashPromotionProductRelationService;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.web.bind.annotation.*;

/**
 * @author Morty
 * @create 2022 11 12 10:34
 */
@RestController
@CrossOrigin(origins = "*")
//活动商品关系
public class SmsFlashPromotionProductRelationController {

    @DubboReference
    SmsFlashPromotionProductRelationService flashPromotionProductRelationService;

    //分页查询不同场次关联及商品信息
    @GetMapping("/flashProductRelation/list")
    public ResultData page(Integer flashPromotionId, Integer flashPromotionSessionId,Integer pageNum,Integer pageSize){
        PageResult pageResult = flashPromotionProductRelationService.pageList(flashPromotionId,flashPromotionSessionId,pageNum,pageSize);
        return ResultData.ok(pageResult,"");
    }
    //修改关联信息
    @PostMapping("/flashProductRelation/update/{id}")
    public ResultData updateById(@RequestBody SmsFlashPromotionProductRelation smsFlashPromotionProductRelation, @PathVariable Integer id){
        flashPromotionProductRelationService.updateById(smsFlashPromotionProductRelation);
        return ResultData.ok("","");
    }
    //删除关联
    @PostMapping("/flashProductRelation/delete/{id}")
    public ResultData deleteById(@PathVariable Integer id){
        flashPromotionProductRelationService.removeById(id);
        return ResultData.ok("","");
    }
}
